home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13567 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  51 lines

  1. Path: onomoto.a2i!onomoto
  2. From: RjB <onomoto@rahul.net>
  3. Newsgroups: comp.lang.eiffel,comp.lang.c,comp.lang.c++,comp.object,comp.software-eng
  4. Subject: Re: Portability of code & skills (Beware of "C" Hackers etc)
  5. Date: 26 Mar 1996 15:21:35 GMT
  6. Organization: Object removeFromSystem
  7. Message-ID: <4j921v$b5q@bug.rahul.net>
  8. References: <31494D29.4D4B@dmu.ac.uk> <DooBwC.8C0@world.std.com> <65O34-3-3RB@herold.franken.de> <4j8177$18ma@saba.info.ucla.edu>
  9. NNTP-Posting-Host: foxtrot.rahul.net
  10. NNTP-Posting-User: onomoto
  11.  
  12. In article <4j8177$18ma@saba.info.ucla.edu>,
  13. Jay Martin <jmartin@cs.ucla.edu> wrote:
  14. >
  15. >>  function CountThem (l: List): integer;
  16. >>  var Count: integer
  17. >>    procedure CountOne (e: ListElement);
  18. >>    begin
  19. >>      if <some condition on e fulfilled> then begin
  20. >>        Count := Count + 1;
  21. >>      end;
  22. >>    end;
  23. >>  begin
  24. >>    ApplyOnList (l, CountOne); (* !!!! *)
  25. >>    CountThem := Count
  26. >>  end;
  27. >
  28. >
  29. >This is what I call side-effects on a global variable (or variable of
  30. >a larger scope).  Its not what I call good programming practice.  In
  31. >fact, I see nested procedures as implemented in algol block languages
  32. >(automatic importation of variables from larger scopes) as another
  33. >stupid idea of CS.  
  34.  
  35.     Hardly:  If CountThem is part of the published interface, then
  36. how Count is used is immaterial.  Not that this matters, because it's
  37. a secondary issue.
  38.  
  39.     The point that you appear to be missing is that procedures and
  40. functions are treated in a first-class manner, which is both powerful
  41. and easy to understand.  Compare this to how C/C++ uses pointers to
  42. functions: it requires a great deal of work to get by the compiler,
  43. and introduces a tremendous succeptibility to error.  And when the
  44. pointers do get munged, finding the bug isn't necessarily easy.
  45.  
  46.     -rj
  47. -- 
  48. onomoto -- 555       | Infoto Diegoto DODOTO Tobagoto vetoto Texacoto
  49. bryant st #136 palo  | <a href="ftp://ftp.rahul.net/pub/onomoto/RjBXerox.gif">
  50. alto ca 94301        | Kyototo Oronoto Orinocoto vivoto GINKGOTO.  
  51.